;;; set-hl-line.el - settings for highlight current line.
;;;  
;;; Copyright (C) 2011 Jeffy Du
;;;  
;;; Author: Jeffy Du (cmdxiaoha@163.com)
;;; Create: 2011-12-23 23:41:44
;;; Last Modified: 2011-12-23 23:42:08
;;;  
;;; History:
;;; --------
;;; 2011-12-23  v0.1  Jeffy Du (cmdxiaoha@163.com)
;;;     1. Initial revision.

(require 'hl-line)

(or (facep 'my-hl-line-face) (make-face 'my-hl-line-face))
(setq hl-line-face 'my-hl-line-face)

(face-spec-set 'my-hl-line-face '((t (
                                      :background "DodgerBlue3"
                                      :inverse-video nil
                                      )))
)

(defun my-color-theme-adjust-hl-mode-face ()
  "interactive"
  (let* ((color (x-color-values (face-attribute 'default :background))))
    (if (null color)
        (add-hook 'find-file-hooks (lambda () (setq hl-line-face 'underline) (hl-line-mode 1)))
      (let ((my-color (mapcar
                       (lambda (x)
                         (let ((y (/ #XFFFF 4))
                               (delta #X18FF))
                           (cond
                            ((< x (* y 1))
                             (+ x delta))
                            ((< x (* y 2))
                             (+ x delta))
                            ((< x (* y 3))
                             (- x delta))
                            (t
                             (- x delta)))))
                       color)))
        (message "%S %S" color my-color)
        (set-face-attribute
         'my-hl-line-face nil
         :background
         (concat "#"
                 (mapconcat
                  (lambda (c) (format "%04X" c))
                  my-color
                  "")))
        (add-hook 'find-file-hooks (lambda () (hl-line-mode t))))))
)
(my-color-theme-adjust-hl-mode-face)
